﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using Access.PowerTools.AbstractionLayer;
using Access.PowerTools.Simulation.Engine;

namespace Access.PowerTools.TestConsole
{
    /// <summary>
    /// This test set was used to make abstraction layer -
    /// quite some code refactoring was involved but
    /// it went smoothly because of
    /// other unit tests' "safety net"
    /// </summary>

    [TestFixture]
    public class TestSet_0005_HostCommunicationBridge
    {
        [SetUp]
        public void Setup()
        {
            Access.PowerTools.Settings.Globals.Init();
            Access.PowerTools.Settings.Globals.SimulationModeOn = true;

            Access.PowerTools.Settings.Globals.HostApplication =
                new Access.PowerTools.Simulation.Engine.SimulationCommunicationBridge();
        }

        [TearDown]
        public void TearDown()
        {
        }

        [Test]
        public void Test_001_InitBridge()
        {
            // see Setup() for host bridge intialization
            AccessApplication app = new AccessApplication();
            Console.WriteLine("{0} - {1}", app.Name, app.Version);

            bool ret = true;

            Assert.IsTrue(ret, System.Reflection.MethodInfo.GetCurrentMethod().Name + "() Failed");
        }

        [Test]
        public void Test_002_ListObjects()
        {
            AccessApplication app = new AccessApplication();
            List<AccessDatabaseObjectInfo> objects = null;
            
            objects = app.CurrentDatabase.AllObjects;
            Console.WriteLine("{0}", objects.Count());

            bool ret = (objects.Count == 73);

            Assert.IsTrue(ret, System.Reflection.MethodInfo.GetCurrentMethod().Name + "() Failed");
        }

    }
}
